//查询作品信息
say.commentary.index.queryArtwork = function(){
	var url = "/say/artwork/rest/getBy/"+say.commentary.index.artworkId;
	$.ajax({
		type: 'GET',
		url: url,
       	dataType:'json',	
       	success: function (result) {	
       		debugger
	   		if(result && result.status){
				if(result.status==1 && result.content){
					$("#ARTWORK_NODE").empty();
					$("#ARTWORK_NODE").append(_.template($("#ARTWORK_ITEM").html())({info: result.content}));
					say.commentary.index.artwork = result.content;
				}else{
					$("#ARTWORK_NODE").html("没有数据");
				}
			}else{
				$("#ARTWORK_NODE").html(result.msg || "请求错误");
			}
       	},
       	error: function(result){
       		$("#ARTWORK_NODE").html("请求错误");
       	}
	});
}


//查询数据 渲染页面
say.commentary.index.query = function(pageNo){
	say.artwork.index.currentPage = pageNo;
	var url = "/say/artwork/rest/queryPage";
	var param = {
		classificationId:say.artwork.index.classificationId,
		pageSize:9,
		pageNo:pageNo
	}
	$.ajax({
		type: 'POST',
		url: url,
       	data: param,
       	dataType:'json',	
       	success: function (result) {	
	   		if(result && result.status){
				if(result.status==1 && result.data){
					$("#ARTWORK_NODE").empty();
					for (var i=0; i<result.data.length; i+=3){
						$("#ARTWORK_NODE").append(_.template($("#ROW_ITEM").html())({i: i}));
						
						$("#ARTWORK_ROW"+i).append(_.template($("#ARTWORK_ITEM").html())({info: result.data[i]}));
						if (i+1<result.data.length) $("#ARTWORK_ROW"+i).append(_.template($("#ARTWORK_ITEM").html())({info: result.data[i+1]}));
						if (i+2<result.data.length) $("#ARTWORK_ROW"+i).append(_.template($("#ARTWORK_ITEM").html())({info: result.data[i+2]}));
					}
					if (result.data.length>0){
						base.jqPaginator("pager",result.page,10,"say.artwork.index.query");
					}
				}else{
					$("#ARTWORK_NODE").html("没有数据");
				}
			}else{
				layer.msg("请求失败",{icon:0});
			}
       	},
       	error: function(result){
       		alert("未知错误");
       	}
	});
}

say.commentary.index.addCommentary = function(){
	
}

say.commentary.clearNavActive = function(){
	$(".nav.navbar-nav li").removeClass("active");
}

$(function(){
	say.account.head.clearNavActive();
	say.commentary.index.queryArtwork();
	
//	say.commentary.index.query(1);
	
	//绑定事件
	$("#addCommentary").on("click",say.commentary.index.addCommentary);	//新增
//	$("#ARTWORK_NODE").on("click",".thumbnail",say.commentary.index.inDetail);
	
	
});
